home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / id3 / writer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-04-10  |  3.5 KB  |  100 lines

  1. // -*- C++ -*-
  2. // $Id: writer.h,v 1.8 2002/07/02 22:11:10 t1mpy Exp $
  3.  
  4. // id3lib: a software library for creating and manipulating id3v1/v2 tags
  5. // Copyright 1999, 2000  Scott Thomas Haug
  6.  
  7. // This library is free software; you can redistribute it and/or modify it
  8. // under the terms of the GNU Library General Public License as published by
  9. // the Free Software Foundation; either version 2 of the License, or (at your
  10. // option) any later version.
  11. //
  12. // This library is distributed in the hope that it will be useful, but WITHOUT
  13. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
  15. // License for more details.
  16. //
  17. // You should have received a copy of the GNU Library General Public License
  18. // along with this library; if not, write to the Free Software Foundation,
  19. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20.  
  21. // The id3lib authors encourage improvements and optimisations to be sent to
  22. // the id3lib coordinator.  Please see the README file for details on where to
  23. // send such submissions.  See the AUTHORS file for a list of people who have
  24. // contributed to id3lib.  See the ChangeLog file for a list of changes to
  25. // id3lib.  These files are distributed with id3lib at
  26. // http://download.sourceforge.net/id3lib/
  27.  
  28. #ifndef _ID3LIB_WRITER_H_
  29. #define _ID3LIB_WRITER_H_
  30.  
  31. #include "id3/globals.h" //has <stdlib.h> "id3/sized_types.h"
  32.  
  33. class ID3_CPP_EXPORT ID3_Writer
  34. {
  35.  public:
  36.   typedef uint32 size_type;
  37.   typedef uint8  char_type;
  38.   typedef uint32 pos_type;
  39.   typedef  int32 off_type;
  40.   typedef  int16 int_type;
  41.   static const int_type END_OF_WRITER;
  42.   
  43.   /** Close the writer.  Any further actions on the writer should fail. **/
  44.   virtual void close() = 0;
  45.  
  46.   /** Flush the writer. **/
  47.   virtual void flush() = 0;
  48.  
  49.   /** Return the beginning position in the writer **/
  50.   virtual pos_type getBeg() { return static_cast<pos_type>(0); }
  51.  
  52.   /** Return the first position that can't be written to.  A return value of
  53.    ** -1 indicates no (reasonable) limit to the writer. 
  54.    **/
  55.   virtual pos_type getEnd() { return static_cast<pos_type>(-1); }
  56.  
  57.   /** Return the next position that will be written to */
  58.   virtual pos_type getCur() = 0;
  59.  
  60.   /** Return the number of bytes written **/
  61.   virtual size_type getSize() { return this->getCur() - this->getBeg(); }
  62.  
  63.   /** Return the maximum number of bytes that can be written **/
  64.   virtual size_type getMaxSize() { return this->getEnd() - this->getBeg(); }
  65.  
  66.   /** Write a single character and advance the internal position.  Note that
  67.    ** the interal position may advance more than one byte for a single
  68.    ** character write.  Returns END_OF_WRITER if there isn't a character to
  69.    ** write.
  70.    **/
  71.   virtual int_type writeChar(char_type ch) 
  72.   {
  73.     if (this->atEnd())
  74.     { 
  75.       return END_OF_WRITER; 
  76.     }
  77.     this->writeChars(&ch, 1);
  78.     return ch;
  79.   }
  80.  
  81.   /** Write up to \c len characters into buf and advance the internal position
  82.    ** accordingly.  Returns the number of characters write into buf.  Note that
  83.    ** the value returned may be less than the number of bytes that the internal
  84.    ** position advances, due to multi-byte characters.
  85.    **/
  86.   virtual size_type writeChars(const char_type buf[], size_type len) = 0;
  87.   virtual size_type writeChars(const char buf[], size_type len)
  88.   {
  89.     return this->writeChars(reinterpret_cast<const char_type *>(buf), len);
  90.   }
  91.  
  92.   virtual bool atEnd()
  93.   {
  94.     return this->getCur() >= this->getEnd();
  95.   }
  96. };
  97.  
  98. #endif /* _ID3LIB_WRITER_H_ */
  99.  
  100.